package a66weding.com.jiehuntong.base;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.view.Window;
import android.widget.FrameLayout;
import android.widget.LinearLayout;

import a66weding.com.jiehuntong.R;
import a66weding.com.jiehuntong.common.utils.CUtils;

import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;

/**
 * 其他 Activity 的基类
 *
 */
@SuppressWarnings("unused")
public abstract class BaseActivity extends AppCompatActivity {
    public LinearLayout mBaseHeadView;
    public FrameLayout mBaseFramContent;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_base);
        onPreInitViewExecute();
        initView();
        onPostCreateExecute();
    }
    private void initView() {
        mBaseFramContent = (FrameLayout) findViewById(R.id.flay_baseactivity_content);
        View contentView = getContentView();
        Log.i("69", "initView: ========contentView====="+contentView);
        if (null != contentView) {
            LayoutParams params = new LayoutParams(MATCH_PARENT, MATCH_PARENT);
            mBaseFramContent.addView(contentView, params);
        }
    }
    /**
     * 获取顶部状态栏view
     * @return
     */
    /**
     * 获取内容视图, 由子类返回对应的布局视图
     */
    protected abstract View getContentView();
    /**
     * 在视图初始化之前执行的方法, 由子类选择实现
     */
    protected void onPreInitViewExecute() { }
    /**
     * 在视图初始化之后执行的方法, 由子类选择实现
     */
    protected void onPostCreateExecute() { }

    @Override
    protected void onStop() {
        super.onStop();
        CUtils.cancelToast();
    }

    @Override
    protected void onDestroy() {
        CUtils.cancelToast();
        super.onDestroy();
    }
}
